import { App } from 'vue'
import * as ElIconModules from '@element-plus/icons'

import {
  ElButton,
  ElTable,
  ElAlert,
  ElAutocomplete,
  ElAvatar,
  ElBacktop,
  ElBadge,
  ElTabs,
  ElIcon,
  ElForm,
  ElInput,
  ElCheckbox,
  ElLink,
  ElContainer,
  ElMenu,
  ElDropdown,
  ElRow,
  ElCol,
  ElSelect,
  ElDatePicker,
  ElBreadcrumb,
  ElPagination,
  ElImage,
  ElPopconfirm,
  ElDialog,
  ElTree,
  ElCard
} from 'element-plus'

const components = [
  ElButton,
  ElTable,
  ElAlert,
  ElAutocomplete,
  ElAvatar,
  ElBacktop,
  ElBadge,
  ElTabs,
  ElIcon,
  ElForm,
  ElInput,
  ElCheckbox,
  ElLink,
  ElContainer,
  ElMenu,
  ElDropdown,
  ElRow,
  ElCol,
  ElSelect,
  ElDatePicker,
  ElBreadcrumb,
  ElPagination,
  ElImage,
  ElPopconfirm,
  ElDialog,
  ElTree,
  ElCard
]

export default {
  install(app: App): void {
    for (const cpn of components) {
      app.use(cpn)
    }
    for (const iconName in ElIconModules) {
      app.component(
        iconName,
        ElIconModules[iconName as keyof typeof ElIconModules]
      )
    }
  }
}
